//
//  parse_nt.cpp
//  cobalt
//
//  Created by Nicolas Godbout on 2013-08-23.
//  Copyright (c) 2013 Nicolas Godbout. All rights reserved.
//

#include "../cobalt/parse_nt.h"

#include <fstream>
#include <iostream>

int test_parse_nt () {
    std::ifstream t("20k.nt");
    assert(t.is_open());
    t.seekg(0, std::ios::end);
    size_t size = t.tellg();
    std::string buffer(size, ' ');
    t.seekg(0);
    t.read(const_cast<char*>(buffer.data()), size);
    
    RDFEnvironment env;
    ParseNT p({}, &env);
    bool flag = p.parse(buffer);
    
    if (flag) {
        printf("Parsed %ld triples.\n\n", p.getGraph()->length());
    }
    else {
        printf("Failed at line #%d\nTriples parsed so far:\n\n", p.getLine());
    }
    NTriplesSerializer  nt;
    std::cout << nt.serialize(*p.getGraph());
    
    return 0;
}